#include <iostream>
using namespace std;

signed main()
{
	int m,n,a,b,q;
	cin>>m>>n>>a>>b>>q;
	int ans[505][505];
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			cin>>ans[i][j];
			if(ans[i][j]>=a&&ans[i][j]<=b)	ans[i][j] = q;
		}
	}
	for(int i=0;i<m;i++){
		printf("%03d",ans[i][0]);
		for(int j=1;j<n;j++){
			printf(" %03d",ans[i][j]);
		}
		cout<<"\n";
	}
	return 0;
}
